package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.SuperMarketBean;
import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;

import java.util.List;

/**
 * 利万嘉超市
 */

public class SuperMaketAdapter extends SuperBaseAdapter<SuperMarketBean.DataBean.MarketBean> {
    private Context mContext;

    public SuperMaketAdapter(Context context, List<SuperMarketBean.DataBean.MarketBean> data) {
        super(context, data);
        mContext = context;
    }

    @Override
    protected void convert(BaseViewHolder holder, SuperMarketBean.DataBean.MarketBean item, int position) {
        double dou = item.getDistance() / 1000;
        double distance = (double) Math.round(dou * 10) / 10;
        Glide.with(mContext).load(item.getImageUrl()).placeholder(R.mipmap.station).error(R.mipmap.station).into((ImageView) holder.getView(R.id.market_image));

        holder.setText(R.id.market_name, item.getMarketName())
                .setText(R.id.market_jianjie, item.getMarketDescribe())
                .setText(R.id.market_xiaoshoulaing, "销量:" + item.getSalesVolume())
                .setText(R.id.market_haoping, "好评度:" + item.getGoodReputationNum())
                .setText(R.id.market_distance, "距离:" + distance + "公里");
    }

    @Override
    protected int getItemViewLayoutId(int position, SuperMarketBean.DataBean.MarketBean item) {
        return R.layout.super_market_item;
    }
}
